package com.cpos.consumerserver.thread;

/*
 *  @创建人  Leiwenlong
 *  @创建时间 2020/11/21
 *  @描述 多线程测试类
 */
public class ThreadContrller implements Runnable {

    private Thread t;

    private String threadName;

    public ThreadContrller(String threadName) {
        this.t = t;
        threadName = threadName;
        //初始化创建
        System.out.println("createIng:  > "+threadName);
    }

    public void threadTest(){

    }

    @Override
    public void run() {
        System.out.println("Running:  >"+threadName);
        try {
        for (int i = 0; i < 5 ; i++) {
            System.out.println(threadName+ i );

                Thread.sleep(50);
            }
        }
        catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public void start(){
        System.out.println("startIng:"+ threadName);
        if(t == null){
            t = new Thread(this,threadName);
            t.start();
        }
    }

    public static void main(String[] args) {
        ThreadContrller t1 = new ThreadContrller("t1");
        t1.start();
        ThreadContrller t2 = new ThreadContrller("t2");
        t2.start();
    }
}
